Skip to content

Switch to AnyCPU for libraries, migrate to slnx#187

Merged
codemonkeychris merged 6 commits into
microsoft:mainfrom
devkanro:feature/anycpu-185
May 8, 2026
Merged

Switch to AnyCPU for libraries, migrate to slnx#187
codemonkeychris merged 6 commits into
microsoft:mainfrom
devkanro:feature/anycpu-185

Conversation

@devkanro
Copy link
Copy Markdown
Contributor

@devkanro devkanro commented May 7, 2026

Summary

Switch to per-project platform declarations: library and WPF projects default to AnyCPU,
WinUI application projects explicitly declare x64;ARM64. Migrate from .sln to .slnx.
Remove shared Platform fallback logic from Directory.Build.props.

Linked issue

Fixes #185

Key changes

Build system

  • Directory.Build.props: Remove Platform fallback logic — only shared config (SDK version) remains
  • Library projects (Reactor, Reactor.Interop.WinForms, Chat.UI, Chat.Model, PerfBench.Shared, StressPerf.Shared, CmdPerf.Shared): no <Platforms> tag, MSBuild defaults to AnyCPU
  • WPF projects (StressPerf.Wpf, CmdPerf.Wpf): no <Platforms> tag — WPF has no native Windows App SDK dependency
  • SelfTests: set WindowsAppSDKSelfContained=false — pure MSTest runner, no WinUI dependency
  • App/test/sample projects: explicit <Platforms>x64;ARM64</Platforms> for WindowsAppSDKSelfContained native assets

Solution migration

  • Reactor.sln → Reactor.slnx: cleaner XML format, solution platforms reduced to x64 and ARM64
  • slnx platform mappings removed for AnyCPU-only projects

CI workflows

  • ci.yml: pass explicit -p:Platform=x64 for standalone project builds
  • coverage.yml: pass explicit -p:Platform=x64; replace hardcoded bin/x64 path with dynamic file lookup
  • release.yml: remove -p:Platform=x64 from solution build/pack (slnx provides it); keep --runtime for publish

Code fixes

  • Update FindHostExe() repo-root lookups in SelfTestBatch, TestSession, WinFormsTestSession, and CompileCommand to search for Reactor.slnx instead of Reactor.sln

Docs

  • Update AGENTS.md, CONTRIBUTING.md, README.md, SKILL.md, PR template, devtools skill

Design

Each project declares its own platform requirements — no shared magic:

Project type Platforms Why
Library (Reactor, Interop, shared libs) AnyCPU (default) IL is always architecture-neutral; no native assets
WPF (StressPerf.Wpf, CmdPerf.Wpf) AnyCPU (default) No Windows App SDK dependency
Analyzer/Generator (netstandard2.0) AnyCPU (inherent) netstandard2.0
SelfTests (MSTest runner) AnyCPU (default) Pure test runner, launches AppTests.Host as subprocess
WinUI App/Test/Sample x64;ARM64 WindowsAppSDKSelfContained needs concrete arch for native DLLs

Solution builds get Platform from the .slnx configuration. Standalone project builds
(e.g. dotnet test tests/Reactor.Tests) require explicit -p:Platform=x64.

Packaging verification

NuGet package — architecture-neutral, same structure as before:

Microsoft.UI.Reactor.nupkg
├── analyzers/dotnet/cs/
│   ├── Reactor.Analyzers.dll              (44.5KB)
│   └── Reactor.Localization.Generator.dll (16KB)
├── lib/net10.0-windows10.0.22621/
│   ├── Reactor.dll                        (2500KB, AnyCPU)
│   ├── Reactor.pri / Reactor.xml
│   └── Reactor/Hosting/ReactorApplication.xaml
└── LICENSE

CLI skill kit — RID-specific layout unchanged:

reactor-skill-kit-<version>.zip
└── reactor/
    ├── SKILL.md, skills/, install-skill-kit.ps1
    ├── bin/x64/    ← mur.exe (158.5KB) + 21 managed DLLs
    └── bin/arm64/  ← mur.exe (136.5KB) + 21 managed DLLs

Test plan

  • dotnet build Reactor.slnx — 0 errors
  • dotnet test tests/Reactor.Tests -p:Platform=x64 — 6819 passed, 46 skipped
  • dotnet test tests/Reactor.SelfTests -p:Platform=x64 — 670 passed
  • dotnet build Reactor.slnx -c Release — succeeds
  • dotnet pack src/Reactor/Reactor.csproj — correct nupkg structure
  • dotnet publish --runtime win-x64 / win-arm64 — both produce valid mur.exe
  • bin/x64/mur.exe mirror layout still works

Risk / breaking changes

  • Developers who used dotnet build/test <project> without -p:Platform for app projects will now need to either build via the solution or pass -p:Platform=x64 explicitly.
  • The .sln file is removed; VS / Rider users need to open Reactor.slnx instead.

Replace the Platform-based architecture selection (x64/ARM64) with
RuntimeIdentifier-based selection. All projects now default to AnyCPU;
the correct native Windows App SDK DLLs are resolved via RuntimeIdentifier
(win-x64/win-arm64) set automatically in Directory.Build.targets based on
machine architecture.

Changes:
- Directory.Build.props: Remove Platform override that forced AnyCPU to
  x64/ARM64
- Directory.Build.targets: Add RuntimeIdentifier default for Windows TFM
  projects (net8.0+) when Platform is AnyCPU
- All ~100 .csproj files: Remove <Platforms>x64;ARM64</Platforms>
- Reactor.Cli: Update MirrorBinForSelfhost to resolve arch from
  RuntimeIdentifier (keeps bin/x64 and bin/arm64 layout)
- Solution file: Update Any CPU/x86 project mappings to use Any CPU
  (instead of remapping to x64)
- release.yml: Remove -p:Platform=x64 from build/pack (keep --runtime
  for publish)
- coverage.yml: Replace hardcoded bin/x64 path with dynamic file lookup
- Update AGENTS.md, CONTRIBUTING.md, README.md, PR template, devtools
  skill doc

The release workflow still produces RID-specific CLI binaries (win-x64 +
win-arm64) for the skill kit. The NuGet package is now architecture-neutral.

Fixes #185

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@devkanro devkanro requested a review from codemonkeychris as a code owner May 7, 2026 05:52
devkanro and others added 2 commits May 7, 2026 14:30
Revise the AnyCPU approach based on feedback:

- Libraries (Reactor, Reactor.Interop.WinForms) explicitly set
  Platform=AnyCPU and Platforms=AnyCPU — they produce architecture-
  neutral IL.
- Application/test projects keep the existing x64/ARM64 platform
  selection via Directory.Build.props (defaults to machine arch).
- WindowsAppSDKSelfContained apps need a concrete architecture for
  native asset resolution; this is supplied by Platform (x64/ARM64).

Also migrates from Reactor.sln to Reactor.slnx:
- Cleaner XML format, no per-project platform mapping boilerplate
- Solution platforms reduced to x64 and ARM64 (removed Any CPU/x86)
- Library projects have no platform mappings (always AnyCPU)

Remove Directory.Build.targets RuntimeIdentifier logic — no longer
needed since apps use Platform directly for native assets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Each project declares its own platform requirements:

- Application/test/sample projects: <Platforms>x64;ARM64</Platforms>
  (need concrete arch for WindowsAppSDKSelfContained native assets)
- Library projects (Reactor, Reactor.Interop.WinForms): no Platforms
  (MSBuild defaults to AnyCPU; IL is always architecture-neutral)
- Analyzers/generators (netstandard2.0): inherently AnyCPU

Directory.Build.props no longer contains Platform fallback logic.
When building a single app project directly, pass -p:Platform=x64
(or ARM64). Solution builds get Platform from the .slnx config.

CI workflows now pass explicit -p:Platform=x64 for standalone
project builds.

Fix SelfTests: pure MSTest runner, no Windows App SDK dependency —
set WindowsAppSDKSelfContained=false and remove Platforms.

Fix .sln → .slnx migration: update FindHostExe() repo-root lookups
in SelfTestBatch, TestSession, WinFormsTestSession, and CompileCommand
to search for Reactor.slnx instead of Reactor.sln.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@devkanro
Copy link
Copy Markdown
Contributor Author

devkanro commented May 7, 2026

@microsoft-github-policy-service agree company="microsoft"

@devkanro devkanro changed the title Switch to AnyCPU platform with RuntimeIdentifier for native assets Switch to AnyCPU for libraries, migrate to slnx May 7, 2026
devkanro and others added 2 commits May 7, 2026 15:12
StressPerf.Wpf and CmdPerf.Wpf target net10.0-windows (no WinAppSDK),
so they don't need WindowsAppSDKSelfContained and can be AnyCPU.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PerfBench.Shared, StressPerf.Shared, StressPerf.Wpf, CmdPerf.Wpf,
Chat.UI, and Reactor.SelfTests no longer declare x64/ARM64 Platforms,
so their slnx entries must not map to those configurations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@codemonkeychris codemonkeychris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the nuget packaging - i think i ended up with x64/arm64 branches in there for the deployment of mur.exe (CLI devtool)... just check that the package generated correctly. @dotMorten has been dogfooding the nuget package from the builds, so I don't want to break him.

@devkanro
Copy link
Copy Markdown
Contributor Author

devkanro commented May 8, 2026

Verified locally — packaging is unchanged.

NuGet package (framework):

Microsoft.UI.Reactor.nupkg
├── analyzers/dotnet/cs/
│   ├── Reactor.Analyzers.dll              (44.5KB)
│   └── Reactor.Localization.Generator.dll (16KB)
├── lib/net10.0-windows10.0.22621/
│   ├── Reactor.dll                        (2500KB, AnyCPU)
│   ├── Reactor.pri                        (1.6KB)
│   ├── Reactor.xml                        (924KB)
│   └── Reactor/Hosting/ReactorApplication.xaml
└── LICENSE

No x64/ARM64 branches — Reactor.dll is architecture-neutral (ProcessorArchitecture: None). Same structure as before this PR.

CLI skill kit (mur.exe): release.yml still publishes with --runtime win-x64 and --runtime win-arm64 separately. Both produce a valid mur.exe + all managed DLLs:

reactor-skill-kit-<version>.zip
└── reactor/
    ├── SKILL.md
    ├── skills/
    ├── install-skill-kit.ps1
    ├── bin/x64/          ← mur.exe (158.5KB, native apphost) + 21 DLLs
    └── bin/arm64/        ← mur.exe (136.5KB, native apphost) + 21 DLLs

mur.dll (196KB) and all other managed DLLs are identical between the two; only mur.exe (the native apphost) differs.

@devkanro devkanro requested a review from codemonkeychris May 8, 2026 03:52
Copy link
Copy Markdown
Collaborator

@codemonkeychris codemonkeychris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codemonkeychris codemonkeychris merged commit 1aa6e02 into microsoft:main May 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Switch to AnyCPU if possible

2 participants